package com.stu.service.impl;

import com.stu.bean.Goods;
import com.stu.bean.Orders;
import com.stu.bean.OrdersExample;
import com.stu.mapper.OrdersMapper;
import com.stu.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class OrdersServiceImpl implements OrdersService {
    @Autowired
    private OrdersMapper ordersMapper;
    public List<Orders> getOrders(Orders orders, Date strDate, Date endDate) {
        return ordersMapper.selectOrders(orders,strDate,endDate);
    }


    public int deleteOrder(int oid) {
        return ordersMapper.deleteByPrimaryKey(oid);
    }

    public Orders insertDd(Orders orders) {

        Orders order = null;
        int o = ordersMapper.insertSelective(orders);
        if(o == 1){
            order = ordersMapper.selectOrdersByname(orders.getOimg());
        }
        return order;
    }

    public int selectOrdersCount() {
        OrdersExample ordersExample=new OrdersExample();
        return ordersMapper.selectByExample(ordersExample).size();
    }
}
